package org.ponly.cta4j.drawing.text.glyphsvisitor;

import org.ponly.cta4j.drawing.text.Glyphs;

import java.awt.geom.Rectangle2D;
import java.security.SecureRandom;
import java.util.Random;

/**
 * @author mag
 * @Date 6 mars 2008
 */
public class RotateGlyphsRandomVisitor implements GlyphsVisitor {

    private double maxAngle = Math.PI / 8;
    private Random myRandom = new SecureRandom();

    public RotateGlyphsRandomVisitor() {
    }

    public RotateGlyphsRandomVisitor(double maxAngle) {
        this.maxAngle = maxAngle;
    }

    public void visit(Glyphs glyphs, Rectangle2D backgroundBounds) {

        for (int i = 0; i < glyphs.size(); i++) {
            glyphs.rotate(i, maxAngle * myRandom.nextGaussian());
        }
    }
}